# #Lagos download script
# #lagosne_get(version='1.087.1',dest_folder = LAGOSNE:::lagos_path())
#
# #Load in lagos
# #lagos <- lagosne_load(version='1.087.1')
#
# #Grab the lake centroid info
# #lake_centers <- lagos$locus
#Plan B:
load('lake_centers.Rdata')
#Look at the column names
#names(lake_centers)
#Look at the structure
#str(lake_centers)
#View the full dataset
#View(lake_centers %>% slice(1:100))
spatial_lakes <- st_as_sf(lake_centers,coords=c('nhd_long','nhd_lat'),
crs=4326) %>%
st_transform(2163)
#Subset for plotting
subset_spatial <- spatial_lakes %>%
slice(1:100)
#Dynamic mapviewer
mapview(subset_spatial)
states <- us_states()
#Plot all the states to check if they loaded
mapview(states)
minnesota <- states %>%
filter(name == 'Minnesota') %>%
st_transform(2163)
#Subset lakes based on spatial position
minnesota_lakes <- spatial_lakes[minnesota,]
#Plotting the first 1000 lakes
minnesota_lakes %>%
slice(1:1000) %>%
arrange(lake_area_ha) %>%
mapview(.,zcol = 'lake_area_ha')
#Your code here
IA_IL <- states %>%
filter(name == 'Iowa'| name == 'Illinois' ) %>%
st_transform(2163)
mapview(IA_IL)
Minnesota has 29,038 lakes while Iowa and Illinois combined have 16,466 lakes.
#Subset lakes based on spatial position
IA_IL_lakes <- spatial_lakes[IA_IL,]
#Plotting the first 1000 lakes
IA_IL_lakes %>%
slice(1:1000) %>%
arrange(lake_area_ha) %>%
mapview(.,zcol = 'lake_area_ha')
IA_MN <- states %>%
filter(name %in% c('Iowa', 'Minnesota')) %>%
st_transform(2163)
IA_MN_lakes <- spatial_lakes %>%
st_join(.,IA_MN) %>%
filter(!is.na(name))
ggplot(IA_MN_lakes, aes(lake_area_ha))+
geom_histogram()+
facet_wrap(~name, ncol=1) +
scale_x_log10()
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
#Plotting the first 1000 lakes
IA_IL_lakes %>%
slice(1:1000) %>%
arrange(lake_area_ha) %>%
mapview(.,zcol = 'lake_area_ha')
We could use NHD High Resolution waterbody data, or satellite imagery along with state shapfiles (such as the package mapview).